unit Tox;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TfTox = class(TForm)
    procedure FormPaint(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    MX, MY, MM: Integer;
    BB: TBitmap;
  public
    { Public declarations }
  end;

var
  fTox: TfTox;

implementation

uses New, Main, uUtils, uImage2;

{$R *.dfm}

procedure TfTox.FormPaint(Sender: TObject);
begin
  Canvas.Draw(0, 0, BB);
end;

procedure TfTox.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if (X >= 0) and (X <= (BB.Width)) then MX := X div 32;
  if (Y >= 0) and (Y <= BB.Height) then MY := Y div 32;
  MM := (MY * (BB.Width div 32)) + MX;
end;

procedure TfTox.FormClick(Sender: TObject);
begin
  if (MM < 0) then Exit;
  fNew.DCC := MM;
  fNew.Image1.Canvas.Draw(0, 0, GetImage(Path + fMain.DungeonTileset, MM));
  ModalResult := mrOK;
end;

procedure TfTox.FormShow(Sender: TObject);
begin
  with fMain do BB.LoadFromFile(Path + DungeonTileset);
  ClientWidth  := BB.Width;
  ClientHeight := BB.Height;
  Canvas.Draw(0, 0, BB);
end;

procedure TfTox.FormCreate(Sender: TObject);
begin
  BB := TBitmap.Create;
end;

procedure TfTox.FormDestroy(Sender: TObject);
begin
  BB.Free;
end;

end.
